home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Where Can I Find Standard C Library S
- Date: 9 Feb 1996 17:13:44 GMT
- Organization: OpenVision
- Message-ID: <4ffvc8$i02@spanky.pls.ov.com>
- References: <3119E6D9.60FD@cmt.lpr.mail.carel.fi>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article 60FD@cmt.lpr.mail.carel.fi, Ari Lukumies <aril@cmt.lpr.mail.carel.fi> writes:
- >Fletcher.Glenn@ov.com wrote:
- >>
- >>
- >> Whoops! for strcpy:
- >>
- >> char *strcpy(char *destination, char *source)
- >> {
- >> char *retval;
- >>
- >> retval = destination;
- >> while((*destination++ = *source++) != '\0');
- >> return(retval);
- >> }
- >> Fletcher.Glenn@ov.com
- >
- >.... And you wonder why printf("%s\n", strcpy(tmp, "thingyam")); may not give correct
- >results using your strcpy version... Try this for size:
- >
- > char *strcpy(char *destination, char *source)
- > {
- > char *retval = destination;
- >
- > do
- > *destination = *source++;
- > while (*destination++ != '\0');
- > return retval;
- > }
- >
- >This will also copy the nul-terminator. :)
- >
- >Later,
- > AriL
- >--
- >All my opinions are mine and mine alone.
-
-
- Actually, you'll notice that mine does copy the null terminator. Note that
- the results of the assignment is used in the test. See K+R2 Pg 105. (I
- did see the smiley.) :-)
-
- Fletcher.Glenn@ov.com
-
-
-